home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Controller / MCComponent ƒ / MyComponentRoutines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-14  |  3.8 KB  |  140 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        MyComponentRoutines.c
  3.     
  4.     Contains:    simple component sample.
  5.  
  6.     Written by:    John Wang
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <1>        03/14/94    JW        Re-Created for Universal Headers.
  13.  
  14.     To Do:
  15.     
  16. */
  17.  
  18. #ifdef THINK_C
  19. #define        applec
  20. #endif
  21.  
  22. #include    <Errors.h>
  23. #include    <Components.h>
  24. #include    <Devices.h>
  25. #include    <Movies.h>
  26. #include    <QuickTimeComponents.h>
  27. #include    <LowMem.h>
  28.  
  29. #include    "MyComponent.h"
  30. #include    "MyComponentRoutines.h"
  31. #include    "FadeScreen.h"
  32. #include    "HideMenuBar.h"
  33.  
  34. /* ------------------------------------------------------------------------- */
  35.  
  36. pascal ComponentResult MyIsPlayerEvent (PrivateGlobals **storage,
  37.             EventRecord *e)
  38. {
  39.     GrafPtr        savePort;
  40.     GDHandle    saveGD;
  41.  
  42.     //    Fade out for the first time.
  43.     if ((**storage).firstTime == true) {
  44.         SwapWindow(storage);
  45.         (**storage).firstTime = false;
  46.     }
  47.     
  48.     //    Handle events
  49.     if (e->what == keyDown) {
  50.         if ((e->message & charCodeMask) == '\t') {
  51.             SwapWindow(storage);
  52.             return(true);
  53.         }
  54.     } else if (e->what == updateEvt) {
  55.         if (e->message == (long) (**storage).backWindow) {
  56.             GetPort(&savePort);
  57.             saveGD = GetGDevice();
  58.             SetPort((**storage).backWindow);
  59.             SetGDevice(GetMainDevice());
  60.             BeginUpdate((**storage).backWindow);
  61.             PaintRect(&(((**storage).backWindow)->portRect));
  62.             EndUpdate((**storage).backWindow);
  63.             SetPort(savePort);
  64.             SetGDevice(saveGD);
  65.             return(true);
  66.         }
  67.     }
  68.     
  69.     //    Handle other events.
  70.     return(MCIsPlayerEvent((**storage).delegate, e));
  71. }
  72.  
  73. //--------------------------------------------------------------------------
  74.  
  75. void SwapWindow(PrivateGlobals **storage)
  76. {
  77.     CGrafPtr            moviePort;
  78.     GDHandle            myDevice;
  79.     Rect                myDeviceRect, movieRect;
  80.     GrafPtr                savePort;
  81.     GDHandle            saveGD;
  82.     RgnHandle            movieRgn;
  83.     
  84.     //    Get variables
  85.     GetPort(&savePort);
  86.     saveGD = GetGDevice();
  87.     GetMovieGWorld(MCGetMovie((**storage).delegate), &moviePort, nil);
  88.     myDevice = GetMaxDevice(&((**LMGetGrayRgn()).rgnBBox));
  89.     myDeviceRect = (**myDevice).gdRect;
  90.     
  91.     FadeInOut(myDevice, true, 60);
  92.     if ((**storage).fadeStatus == false) {
  93.         //    Hide the menu bar
  94.         (**storage).handleBarStorage = HideMenuBar();
  95.  
  96.         //    Modify movie controller.
  97.         (**storage).mcVisible = MCGetVisible((**storage).delegate);
  98.         (**storage).mcAttached = MCIsControllerAttached((**storage).delegate);
  99.         MCSetVisible((**storage).delegate, false);
  100. //        MCSetControllerAttached((**storage).delegate, false);
  101.         movieRgn = MCGetWindowRgn((**storage).delegate, (WindowPtr) moviePort);
  102.         SizeWindow((WindowPtr) moviePort, ((**movieRgn).rgnBBox).right - ((**movieRgn).rgnBBox).left,
  103.                         ((**movieRgn).rgnBBox).bottom - ((**movieRgn).rgnBBox).top, true);
  104.         DisposeRgn(movieRgn);
  105.         
  106.         //    Create back window.
  107.         (**storage).backWindow = NewCWindow(0L, &myDeviceRect, "\pBlack Background", 1, noGrowDocProc, (WindowPtr) -1, false, 0L);
  108.         SelectWindow((**storage).backWindow);
  109.         SetPort((**storage).backWindow);
  110.         SetGDevice(GetMainDevice());
  111.         PaintRect(&(((**storage).backWindow)->portRect));
  112.         
  113.         //    Modify movie window.
  114.         SetPort((GrafPtr) moviePort);
  115.         SetGDevice(GetMainDevice());
  116.         SelectWindow((WindowPtr) moviePort);
  117.         (**storage).fadeStatus = true;
  118.     } else {
  119.         //    Restore menu bar.
  120.         RestoreMenuBar((**storage).handleBarStorage);
  121.  
  122.         //    Restore movie controller.
  123.         MCSetVisible((**storage).delegate, (**storage).mcVisible);
  124.         MCSetControllerAttached((**storage).delegate, (**storage).mcAttached);
  125.         movieRgn = MCGetWindowRgn((**storage).delegate, (WindowPtr) moviePort);
  126.         SizeWindow((WindowPtr) moviePort, ((**movieRgn).rgnBBox).right - ((**movieRgn).rgnBBox).left,
  127.                         ((**movieRgn).rgnBBox).bottom - ((**movieRgn).rgnBBox).top, true);
  128.         DisposeRgn(movieRgn);
  129.  
  130.         //    Dispose back window.
  131.         SelectWindow((**storage).backWindow);
  132.         DisposeWindow((**storage).backWindow);
  133.         (**storage).fadeStatus = false;
  134.     }
  135.     FadeInOut(myDevice, false, 60);
  136.  
  137.     SetPort(savePort);
  138.     SetGDevice(saveGD);
  139. }
  140.